﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using Framework.UI;
using Framework.Util;
using Framework.Manager;

namespace Game.UI
{
    public class MainPanelView : ViewBase<MainPanelController>
    {
        private List<Texture> mList = new List<Texture>();
        protected override void OnInit()
        {
            Debug.LogError("MainView Init");
            foreach (KeyValuePair<string, Texture> kvp in ManagerCollection.ResourceManager.mTextureDictionary)
            {
                mList.Add(kvp.Value);
            }
        }

        public void SetSprite()
        {
            int index = Random.Range(0, mList.Count);
            Texture2D texture2D = mList[index] as Texture2D;
            Image uiImage = GetComponent<Image>("UIImage");
            uiImage.sprite = Sprite.Create(texture2D, new Rect(0, 0, texture2D.width, texture2D.height), new Vector2(0.5f, 0.5f));
            uiImage.SetNativeSize();
        }
    }
}